<?php
require_once(SITE_ROOT."/includes/Templatized.php");
abstract class Page implements Templatized {
    public function prepare() {
        global $gSmarty;
        $gSmarty->assign("realurl", $_SERVER['REQUEST_URI']);
        $gSmarty->assign("realquerystring", $_SERVER['QUERY_STRING']);
        $hour = intval(date('G'));
        if ($hour >= 2 && $hour <= 6) {
            $gSmarty->assign("time_restricted", 1);
        }

        if (array_key_exists('NR', $_COOKIE) && $_COOKIE['NR'] != "0") {
            $userid = $_SESSION['G_USERID'];
            //FaceKooElement::markNotificationsRead($userid, $_COOKIE['NR']);
            setcookie('NR', '0', 0, '/');
        }
        $uid = $_REQUEST['uid'];
        if ($uid!="" && $uid != $_SESSION['G_USERID']) {
            $userid = $uid;
            $gSmarty->assign("if_self", 0);
        } else {
            $userid = $_SESSION['G_USERID'];
            $gSmarty->assign("if_self", 1);
        }
    }
    public function redirect($url) {
        header("Location: $url");
        exit;
    }
    public function display() {
        global $gSmarty;
        if ($this->getTemplate()==='') {
            trigger_error('Template is empty - url='.$_SERVER['REQUEST_URI']);
        } else {
            $gSmarty->display($this->getTemplate());
        }
    }
}

?>
